#!/bin/bash
# version: 1.2
# date: 2022/05/31
# 需要安装依赖包: acpi
# 安装命令: sudo pacman -S acpi

get_bettery(){
    # Change BAT1 to whatever your battery is identified as. Typically BAT0 or BAT1
    NUM=$(cat /sys/class/power_supply/BAT0/capacity)
    STATUS=$(cat /sys/class/power_supply/BAT0/status)

    if [ "$NUM" -le 33   ]; then
        if [ "$STATUS" = "Discharging" ]; then
            printf " %s" "$NUM"
        else
            printf " %s" "$NUM"
        fi
    elif [ "$NUM" -ge 33 ] && [ "$NUM" -le 66 ]; then
        if [ "$STATUS" = "Discharging" ]; then
            printf " %s" "$NUM"
        else
            printf " %s" "$NUM"
        fi
    else
        if [ "$STATUS" = "Discharging" ]; then
            printf " %s" "$NUM"
        else
            printf " %s" "$NUM"
        fi
    fi
}

get_bettery
